<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	UserBean user = (UserBean) request.getSession().getAttribute(
			"userBean");

	String _db = user.getDbType();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript"
			src="ligerUI/js/plugins/ligerDateEditor.js"></script>

		<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.jcqkgl.only_childParent_retireAction";
_jsonObj.methodname = "";
_jsonObj.logicdata = "[]";

var win;//人员新建/修改弹出框

$(function(){
	manager = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height:'100%',heightDiff:-30,
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,onAfterShowData: function(data, currentPageData)
		 {
		 	//allProps(data);
		     if(data.Total>0)
		     {
		    	 $("#Total").val(data.Total);
			     $("#TotalMon").val(data.Total*<%=user.getGlobalMap().get("Retirement")%>);
			     $("#Totaled").val(data.Totaled);
			     $("#TotalMoned").val(data.Totaled*<%=user.getGlobalMap().get("Retirement")%>);
			     var totales = data.Total-data.Totaled;
			     $("#Totals").val(totales);
			     $("#TotalMons").val(totales*<%=user.getGlobalMap().get("Retirement")%>);
		     }
		     else
		     {
		     	 $("#Total").val(0);
			     $("#TotalMon").val(0);
			     $("#Totaled").val(0);
			     $("#TotalMoned").val(0);
			     $("#Totals").val(0);
			     $("#TotalMons").val(0);
		     }
		 },
                columns: [
                { display:'trpocrr_id', name:'trpocrr_id', width:1,hide:true},
                { display:'org_id', name:'org_id', width:1,hide:true},
                { display:'tbe_id', name:'tbe_id', width:1,hide:true},
	            { display: '机构名称', name: 'reserve1', width: 150, align: 'left'},
				{ display: '是否发放', name: 'reserve2', align: 'left',width:100,
                	render: function (row)
                    {
                       var html = ' ';
                       if(row.reserve2=='1'){
                       		html = '已发放';
                       }else{
                       		html = '未发放';
                       }
                       return html;
                    } 
                },
                { display:'姓名', name:'trpocrr_name',align: 'left',width:150,render: function(record, index, value, oth){
						return " <a href='javascript:addData(" + JSON.stringify(record) + ")'>"+value+"</a>";
					}
				},
                { display: '性别', name: 'trpocrr_sex',width: 50,align: 'left'},
                { display:'年龄', name:'trpocrr_age', width:1,hide: true},
                { display:'出生日期', name:'trpocrr_birthday',width: 100,align: 'left'},
                { display:'职级', name:'trpocrr_position',align: 'center',width:150,
                	render: function (row)
                    {
                       var html = ' ';
                       if(row.trpocrr_position=='1'){
                       		html = '专业技术管理';
                       }else if(row.trpocrr_position=='2'){
                       		html = '生产操作服务';
                       }
                       return html;
                    } 
                },
                { display:'独生子女证领取时间', name:'trpocrr_ocr_time', align: 'left',width:180},
                { display:'领取金额', name:'trpocrr_get_money',  align: 'left',width:180},
                { display:'领取奖励时间', name:'trpocrr_time', align: 'left',width:180},
                { display:'领取人', name:'trpocrr_person',align: 'left',width:150},
                { display:'备注', name:'trpocrr_memo',hide:true,width:1},
				{ display: 'reserve3', name: 'reserve3', width:  1, hide:true },
				{ display: 'reserve4', name: 'reserve4', width:  1, hide:true },
				{ display: 'reserve5', name: 'reserve5', width:  1, hide:true },
				{ display: '录入人', name: 'create_by', width:  1, hide:true },
				{ display: '录入时间', name: 'create_time', width:  1, hide:true },
				{ display: '最后修改人', name: 'last_modify_by', width:  1, hide:true },
				{ display: '最后修改时间', name: 'last_modify_time', width: 1, hide:true },
                {
                    display: '编辑', name: 'user_id',width: 60,isSort:false,
                    render: function (row){
                       return "<img src='ligerUI/skins/icons/edit.gif' onclick='addData("+JSON.stringify(row)+")'></img>";
                    }
                }],
                
                toolbar: {
                	items: [
                		{ text: '发放', click: function(){ updateData(); }, icon: 'add' },
						{ line: true },
		                { text: '取消', click: function(){ delData(); },icon: 'delete'}
	                ]
                }
            });

	
	/*
	 * 日期框
	 */
	$("#trpocrr_birthday").ligerDateEditor({ format: "yyyy-MM-dd", width:182 });
	$("#trpocrr_ocr_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#trpocrr_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#ser4").ligerDateEditor({ format: "yyyy-MM-dd", width:164});
	$("#ser5").ligerDateEditor({ format: "yyyy-MM-dd", width:164});
});

/*
 * 表格刷新
 */
function reload(){
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = "[{\"types\":\"init\"}]";
	manager.loadData();
}

/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	serch1();
	if(data.result || data.result == 'true'){
		succMsgTip(data.resultrecord);
	}else{
		warningTip(data.resultrecord);
	}
	if(win && data.result){
		win.hide();
	}
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}

/*
 * 获取列表选中的人员ID
 */
function getUserIds(){
	var arrayUsers = manager.getSelecteds();
	if(arrayUsers.length == 0){
		return "";
	} else {
		var text = "";
		for(var i=0; i<arrayUsers.length; i++){
			text += arrayUsers[i].trpocrr_id + ",";
		}
		return text.substring(0, text.length - 1);
	}
}

/*
 * 新增/修改人员
 */
function addData(row){
	document.getElementById('emp-form').reset();
	$("#trpocrr_birthday").ligerGetDateEditorManager().setDisabled();
	$("#trpocrr_ocr_time").ligerGetDateEditorManager().setDisabled();
	$("#trpocrr_position").attr("disabled", true);
	if(row){
		loadForm("emp-form", row);
		$("input[name='trpocrr_sex']").attr("disabled", true);
		$("#org_id").attr("disabled", true);
	} else {
		$("#trpocrr_id").val('');
	}
	
	if(win == null){
		win = initWindowByDiv('empAdd-div', '编辑信息', 600, 250 ,save, closeWin);
	}else{
		win.show();
	}
}

/*
 * 新建/修改人员信息
 */
function save(){
	$("#org_id").attr("disabled", false);
	$("#trpocrr_position").attr("disabled",false);
	var trpocrr_person = $("#trpocrr_person").val().trim();
	var trpocrr_memo = $("#trpocrr_memo").val().trim();
	if(!checkIsString(trpocrr_person)){
		warningTip("缴款人：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(trpocrr_person) > 32){
		warningTip("缴款人：不能超过32字符");
		return;
	}
	if(!checkIsString(trpocrr_memo)){
		warningTip("备注：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(trpocrr_memo) > 512){
		warningTip("备注：不能超过512字符");
		return;
	}
	$("input[name='trpocrr_sex']").attr("disabled", false);

	var text = document.getElementById('org_id');
	text = text.options[text.selectedIndex].text.replaceAll('-','');
	$('#reserve1').val(text);
	$('#reserve2').val('1');//标记为已发放
	_jsonObj.logicdata = getForm("emp-form");
	var tbeocr_id = $("#trpocrr_id").val();
	if(tbeocr_id == ''){
		_jsonObj.methodname = "save";
		callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
	} else {
		_jsonObj.methodname = "update";
		callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
	}
}

/*
 * 删除人员
 */
function delData(){
	var userIds = getUserIds();
	if(userIds == ""){
		warningTip('请至少选择一个数据进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？（删除不可恢复）', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "delete";
			_jsonObj.logicdata = "[{\"ids\":\"" + userIds + "\"}]";
			callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
		}
	});
}

/*
 * 发放
 */
function updateData(){
	var arrayUsers = manager.getSelecteds();
	if(arrayUsers.length == 0){
		warningTip('请至少选择一个数据进行操作');
		return;
	} else {
		var text = "";
		for(var i=0; i<arrayUsers.length; i++){
			if(arrayUsers[i].trpocrr_id=='')
			{
				text += "'"+arrayUsers[i].tbe_id +"'"+ ",";
			}
		}
		 var userIds = text.substring(0, text.length - 1);
		_jsonObj.methodname = "updatedata";
		_jsonObj.logicdata = "[{\"ids\":\"" + userIds + "\"}]";
		callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
	}
}

/*
 * 重置-条件查询
 */
function serReset(){
	$('#ser1').val('');
	$('#ser2').val('');
	$('#ser3').val('2');
}

/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#org2').val();
	var reserve2 = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var trpocrr_position = $('#ser2').val();
	var time1 = $('#ser4').val();
	var time2 = $('#ser5').val();
	
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds	+ '\",\"tbe_name\":\"' + tbe_name + '\",\"trpocrr_position\":\"' + trpocrr_position
			 + '\",\"time1\":\"' + time1 + '\",\"time2\":\"' + time2+ '\",\"reserve2\":\"' + reserve2 + '\",\"types\":\"serch1\"}]';
	manager.loadData();
}

/*
 * 条件导出查询
 */
function expData(){
	var orgIds = $('#org2').val();
	var reserve2 = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var trpocrr_position = $('#ser2').val();
	var time1 = $('#ser4').val();
	var time2 = $('#ser5').val();
	
	_jsonObj.methodname = "expData";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_name\":\"' + tbe_name+ '\",\"trpocrr_position\":\"' + trpocrr_position
			+ '\",\"time1\":\"' + time1 + '\",\"time2\":\"' + time2+ '\",\"reserve2\":\"' + reserve2 +'\"}]';
	
	callserver(_jsonObj, function(data, textStatus){
		if(data.result){
			downloadFile(data.resultrecord);
		} else {
			warningTip(data.resultrecord);
		}
	}, function(data, textStatus){
	});
}
</script>
	</head>
	<body>
		<table id="aaa" class="serTable">
			<tr>
				<td>
					机构：
				</td>
				<td>
					<select id="org2" style="width: 164px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td>
					姓名：
				</td>
				<td>
					<input id="ser1" style="width: 160px;" />
				</td>
				<td>
					职级：
				</td>
				<td>
					<select id="ser2" style="width: 164px;">
						<option value="0">
							全部
						</option>
						<option value="1">
							专业技术管理
						</option>
						<option value="2">
							生产操作服务
						</option>
					</select>
				</td>
				<td>
					<input class="btn2" value="搜索" type="button" onclick="serch1();" />
				</td>
			</tr>
			<tr>

				<td>
					是否发放：
				</td>
				<td>
					<select id="ser3" style="width: 164px;">
						<option value="2">
							全部
						</option>
						<option value="0">
							未发放
						</option>
						<option value="1">
							已发放
						</option>
					</select>
				</td>
				<td>
					退休时间：
				</td>
				<td>
					<input id="ser4" onkeyup="this.value=formatdata(this.value);" />
				</td>
				<td>
					--
				</td>
				<td>
					<input id="ser5" onkeyup="this.value=formatdata(this.value);" />
				</td>
				<td>
					<input class="btn2" value="导出" type="button" onclick="expData();" />
				</td>
			</tr>
		</table>

		<div id="emp-grid"></div>
		<div style="font-size: 15px; text-align: left; margin-top: 5px;">
			已发放
			<input type="text" id="Totaled" style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人, 未发放
			<input type="text" id="Totals" style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人, 总人数
			<input type="text" id="Total" style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人, 已发放
			<input type="text" id="TotalMoned"
				style="border: 0; width: 100px; border-bottom: 1px solid #000; text-align: center;" />
			元, 未发放
			<input type="text" id="TotalMons"
				style="border: 0; width: 100px; border-bottom: 1px solid #000; text-align: center;" />
			元, 总金额
			<input type="text" id="TotalMon"
				style="border: 0; width: 100px; border-bottom: 1px solid #000; text-align: center;" />
			元。
		</div>
		<div id="empAdd-div" style="display: none;">
			<form id="emp-form" name="emp-form">
				<input type="hidden" id="trpocrr_id" name="trpocrr_id" value="" />
				<input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
				<input type="hidden" id="create_by" name="create_by" value="" />
				<input type="hidden" id="create_time" name="create_time" value="" />
				<input type="hidden" id="last_modify_by" name="last_modify_by"
					value="" />
				<input type="hidden" id="last_modify_time" name="last_modify_time"
					value="" />

				<table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div
								style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>基础信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">
							机构：
						</td>
						<td>
							<select id="org_id" name="org_id" style="width: 182px;">
								<%=user.getCurSubOrgOptions()%>
							</select>
						</td>
						<td></td>
						<td class="form_label">
							姓名：
						</td>
						<td>
							<input class="textbg1" id="trpocrr_name" name="trpocrr_name"
								readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							出生日期：
						</td>
						<td>
							<input id="trpocrr_birthday" name="trpocrr_birthday" readonly="readonly" />
						</td>
						<td></td>
						<td class="form_label">
							领证时间：
						</td>
						<td>
							<input id="trpocrr_ocr_time" name="trpocrr_ocr_time"
								readonly="readonly" />
						</td>
						<td></td>
					</tr>
					<tr style="display: none;">
						<td class="form_label">
							年龄
						</td>
						<td>
							<input class="textbg1" id="trpocrr_age" name="trpocrr_age"
								readonly="readonly" value="0"
								onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							职级：
						</td>
						<td>
							<select id="trpocrr_position" name=trpocrr_position
								style="width: 182px;">
								<option value="2">
									生产操作服务
								</option>
								<option value="1">
									专业技术管理
								</option>
							</select>
						</td>
						<td></td>
						<td class="form_label">
							性别：
						</td>
						<td align="left" id="trpocrr_sex">
							<input style="margin-top: 2px;" type="radio" name="trpocrr_sex"
								value="男" checked="checked" />
							男
							<input style="margin-top: 2px;" type="radio" name="trpocrr_sex"
								value="女" />
							女
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							领取金额：
						</td>
						<td>
							<input class="textbg1" id="trpocrr_get_money"
								name="trpocrr_get_money" readonly="readonly" value="0"
								onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">
							领取奖励时间：
						</td>
						<td>
							<input id="trpocrr_time" name="trpocrr_time"
								onkeyup="this.value=formatdata(this.value);" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							领取人：
						</td>
						<td>
							<input class="textbg1" id="trpocrr_person" name="trpocrr_person"
								onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">
							备注：
						</td>
						<td>
							<input class="textbg1" id="trpocrr_memo" name="trpocrr_memo"
								onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td>
							<br />
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>